package com.huonan.jb.tools.esuse.config;

import cn.hutool.setting.dialect.Props;
import cn.hutool.setting.dialect.PropsUtil;
import com.huonan.jb.tools.esuse.dto.Configs;
import com.huonan.jb.tools.esuse.export.enums.Env;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
@Slf4j
public class PropConfig {
    public static Integer getThreadSize(String argFile) {
        Props props1 = PropsUtil.get(argFile);
        String threadCount = props1.getStr("thread_count");
        if (StringUtils.isEmpty(threadCount)) {
            return 1;
        } else {
            return Integer.parseInt(threadCount);
        }
    }
    @NotNull
    public static Configs getConfigs(Env env, Props props) {
        String outFile = props.getStr("outFile");
        String index = props.getStr("index");
        String sql = props.getStr("sql");
        String scrollId = props.getStr("scrollId");
//        log.info("【查询参数】");
//        log.info("环境:{}",env.name());
//        log.info("sql:{}",sql);
//        log.info("index:{}",index);
//        log.info("outFile:{}",outFile);
        return new Configs(outFile,index,sql, scrollId);
    }
}
